﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class GuildSchoolConfig extends Object
    {
        private var _map:Dictionary;
        public var maxKey:String = "0";
        private static var _instance:GuildSchoolConfig;

        public function GuildSchoolConfig()
        {
            this._map = new Dictionary();
            if (_instance != null)
            {
                throw new Error(" GuildSchoolConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_guild_school_target.json");
            this.write(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TGuildSchoolTarget = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TGuildSchoolTarget();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (!this._map)
                {
                    this._map = new Dictionary();
                }
                this._map[_loc_2.schoolLevel] = _loc_2;
                if (_loc_2.schoolLevel > int(this.maxKey))
                {
                    this.maxKey = _loc_2.schoolLevel.toString();
                }
            }
            return;
        }// end function

        public function getInfoByLevel(param1:int) : TGuildSchoolTarget
        {
            return this._map[param1];
        }// end function

        public function getLevelById(param1:String, param2:int) : int
        {
            var _loc_4:TGuildSchoolTarget = null;
            var _loc_3:int = 1;
            while (_loc_3 <= int(this.maxKey))
            {
                
                _loc_4 = this._map[_loc_3];
                if (_loc_4[param1] >= param2)
                {
                    return _loc_3;
                }
                _loc_3++;
            }
            return _loc_3;
        }// end function

        public function getMap() : Dictionary
        {
            return this._map;
        }// end function

        public static function get instance() : GuildSchoolConfig
        {
            if (_instance == null)
            {
                _instance = new GuildSchoolConfig;
            }
            return _instance;
        }// end function

    }
}
